#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f;
ll blank[200000];

int main()
{
	int t;
	cin>>t;
	for(ll i=2;i<200000;i++)
	{
		blank[i]=i*i-i*i/2;
	}
	while(t--)
	{
		ll a,b,c;
		cin>>a>>b;
		c=max(a,b);
		if(a*b==0 && c==1)
		{
			cout<<1<<endl;
			continue;
		}
		
		
		int l=2;
		int r=2e5-1;
		while(l<r)
		{
			int mid=l+r>>1;
			if(blank[mid]>=c) r=mid;
			else l=mid+1;
		}
		if(l%2==1)
		{
			if(min(a,b)==c && c==blank[l])
			{
				l++;
			}
		 } 
		 cout<<l<<endl;
	}

	return 0;
}

